<script setup lang="ts">
const props = defineProps({
  discount: {
    type: Number,
    default: null
  }
});
</script>

<template>
<span class="tag" v-if="constantStore().calcDiscount(props.discount) > 0">
    <span class="tag-l"></span>
    <span class="tag-r">{{ constantStore().calcDiscount(props.discount) }}折</span>
</span>
</template>

<style scoped lang="scss">
.tag,
.tag-l,
.tag-r {
  display: inline-block;
}

.tag {
  position: relative;
}

.tag-l {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 0;
  height: 0;
  border-top: 10px solid #ba3038;
  border-right: 5px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 5px solid transparent;
  transform: rotatez(-140deg);
}

.tag-r {
  font-size: 12px;
  line-height: 20px;
  color: #fff;
  background: #dc2f2f;
  position: relative;
  width: auto;
  height: 20px;
  margin: 0 10px;
  padding: 0 5px;
}

.tag-r::before {
  content: "";
  position: absolute;
  right: 100%;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-right: 5px solid #dc2f2f;
  border-bottom: 10px solid #dc2f2f;
  border-left: 5px solid transparent;
}

.tag-r::after {
  content: "";
  position: absolute;
  left: 100%;
  width: 0;
  height: 0;
  border-top: 10px solid #dc2f2f;
  border-right: 7.5px solid transparent;
  border-bottom: 10px solid #dc2f2f;
}


</style>